/*
 * Selling Partner API for Easy Ship
 * Use the Selling Partner API for Easy Ship to build applications for sellers to manage and ship Amazon Easy Ship orders. With this API, you can get available time slots, schedule and reschedule Easy Ship orders, and print shipping labels, invoices, and warranties. To review the differences in Easy Ship operations by marketplace, refer to [Marketplace support](https://developer-docs.amazon.com/sp-api/docs/easyship-api-v2022-03-23-use-case-guide#marketplace-support).
 *
 * OpenAPI spec version: 2022-03-23
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */

package software.amazon.spapi.models.easyship.v2022_03_23;

import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

/**
 * An error code that identifies the type of error that occurred. The error codes listed below are specific to the Easy
 * Ship section.
 */
@JsonAdapter(Code.Adapter.class)
public enum Code {
    @SerializedName("InvalidInput")
    INVALIDINPUT("InvalidInput"),
    @SerializedName("InvalidTimeSlotId")
    INVALIDTIMESLOTID("InvalidTimeSlotId"),
    @SerializedName("ScheduledPackageAlreadyExists")
    SCHEDULEDPACKAGEALREADYEXISTS("ScheduledPackageAlreadyExists"),
    @SerializedName("ScheduleWindowExpired")
    SCHEDULEWINDOWEXPIRED("ScheduleWindowExpired"),
    @SerializedName("RetryableAfterGettingNewSlots")
    RETRYABLEAFTERGETTINGNEWSLOTS("RetryableAfterGettingNewSlots"),
    @SerializedName("TimeSlotNotAvailable")
    TIMESLOTNOTAVAILABLE("TimeSlotNotAvailable"),
    @SerializedName("ResourceNotFound")
    RESOURCENOTFOUND("ResourceNotFound"),
    @SerializedName("InvalidOrderState")
    INVALIDORDERSTATE("InvalidOrderState"),
    @SerializedName("RegionNotSupported")
    REGIONNOTSUPPORTED("RegionNotSupported"),
    @SerializedName("OrderNotEligibleForRescheduling")
    ORDERNOTELIGIBLEFORRESCHEDULING("OrderNotEligibleForRescheduling"),
    @SerializedName("InternalServerError")
    INTERNALSERVERERROR("InternalServerError");

    private String value;

    Code(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return String.valueOf(value);
    }

    public static Code fromValue(String input) {
        for (Code b : Code.values()) {
            if (b.value.equals(input)) {
                return b;
            }
        }
        return null;
    }

    public static class Adapter extends TypeAdapter<Code> {
        @Override
        public void write(final JsonWriter jsonWriter, final Code enumeration) throws IOException {
            jsonWriter.value(String.valueOf(enumeration.getValue()));
        }

        @Override
        public Code read(final JsonReader jsonReader) throws IOException {
            Object value = jsonReader.nextString();
            return Code.fromValue((String) (value));
        }
    }
}
